package gomz.pres;

import gomz.GlobalRes;
import gomz.pres.admin.CAAccount;
import gomz.pres.admin.CACategoryadministration;
import gomz.pres.admin.CAExport;
import gomz.pres.admin.CAHexagramadministration;
import gomz.pres.admin.CAImport;
import gomz.pres.admin.CAUseradministration;
import gomz.pres.admin.MVerwaltung;
import gomz.pres.question.CQHexagram;
import gomz.pres.question.CQOverview;
import gomz.pres.question.CQQuestion;
import gomz.pres.question.MQuestion;
import gomz.res.User;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 * Diese Klasse steuert das UI GUIMain. Es reagiert auf die Eingaben des
 * Benutzers.
 * 
 * @author Murillo
 * @author Dilji
 */

public class CMain {

	// ********************************************************************************
	// Variablen
	// ********************************************************************************

	private GUIMain view;

	// Question
	private MQuestion modelQ;
	private CQOverview cOverview;
	private CQQuestion cQuestion;
	private CQHexagram cKonhex, cPerhex, cKomhex, cWenhex, cNukhex, cFuxhex, cLinhex;

	// Admministration
	private MVerwaltung modelV;
	private CAAccount cAaccount;
	private CACategoryadministration cCatAdmin;
	private CAExport cExport;
	private CAHexagramadministration cHexAdmin;
	private CAImport cImport;
	private CAUseradministration cUserAdmin;

	// ********************************************************************************
	// Konstruktor
	// ********************************************************************************

	/**
	 * Konstruktor fuer den Controller des Hauptfensters Fragestellung
	 */

	public CMain() {
		// Model
		modelQ = new MQuestion();
		// Pointer auf selbe Kategorien, Fragen setzten. Aenderungen sollen
		// ueberall stattfinden.
		modelV = new MVerwaltung(modelQ.getCategories(), modelQ.getQuestionCoresAll());

		// View
		this.view = new GUIMain(modelQ, modelV);
		// set window at center of screen
		view.setLocationRelativeTo(null);

		// Controller
		// Question
		cOverview = new CQOverview(view, view.getTabOverview(), modelQ);
		cQuestion = new CQQuestion(view, view.getTabQuestion(), modelQ);
		cKonhex = new CQHexagram(view, view.getTabKonhex(), modelQ, 0, false);
		cPerhex = new CQHexagram(view, view.getTabPerhex(), modelQ, 1, false);
		cKomhex = new CQHexagram(view, view.getTabKomhex(), modelQ, 2, false);
		cWenhex = new CQHexagram(view, view.getTabWenhex(), modelQ, 3, false);
		cNukhex = new CQHexagram(view, view.getTabNukhex(), modelQ, 4, false);
		cFuxhex = new CQHexagram(view, view.getTabFuxhex(), modelQ, 5, false);
		cLinhex = new CQHexagram(view, view.getTabLinhex(), modelQ, 6, false);

		// Administration
		cAaccount = new CAAccount(view, view.getTabAccount(), modelV);
		cCatAdmin = new CACategoryadministration(view, view.getTabCategoryadministration(), modelV);
		cExport = new CAExport(view, view.getTabExport(), modelV);
		cHexAdmin = new CAHexagramadministration(view, view.getTabHexagramadministration(), modelV);
		cImport = new CAImport(view, view.getTabImport(), modelV);
		cUserAdmin = new CAUseradministration(view, view.getTabUseradministration(), modelV);

		addListener();

		// Hexagramme-Tabs disabled
		setHomeHexTabsEnable(false);

		User activUser = GlobalRes.getActivUser();
		view.setLbUserName(activUser.getUsername());
	}

	// Author Dilji
	// ********************************************************************************
	// Listener
	// ********************************************************************************

	/**
	 * Ereignisbehandlung der Buttons in der Icon- und Menueleiste.
	 */
	private void addListener() {

		// Menueleiste
		// ****************************************************************
		// MenuItem Datei - > Home
		view.getMiHome().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doViewHome();
			}
		});

		// MenuItem Datei - > Verwaltung
		view.getMiAdmin().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doViewAdministration();
			}
		});

		// MenuItem Datei - > Schliessen
		view.getMiClose().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// Programm schliessen
				System.exit(0);
			}
		});

		// MenuItem Bearbeiten -> Neue Frage
		view.getMiNewQuestion().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doViewHome();
				cOverview.doNew();
			}
		});

		// MenuItem Bearbeiten -> Oeffnen
		view.getMiOpen().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doOpen();
			}
		});

		// MenuItem Bearbeiten -> Speichern
		view.getMiSave().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doSave();
			}
		});

		// MenuItem Bearbeiten -> Loeschen
		view.getMiDelete().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doDelete();
			}
		});

		// MenuItem Hilfe -> Hilfe
		view.getMiHelp().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doViewHelp();
			}
		});

		// MenuItem Hilfe -> Info
		view.getMiInfo().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doViewInfo();
			}
		});

		// Iconleiste
		// *****************************************************************
		// Icon Home
		view.getBtIconHome().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doViewHome();
			}
		});

		// Icon Verwaltung
		view.getBtIconAdministration().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doViewAdministration();
			}
		});

		// Icon Editieren
		view.getBtIconEdit().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// open-methode ist fuer edit
				doOpen();
			}
		});

		// Icon Neu
		view.getBtIconNew().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doNew();
			}
		});

		// Icon Speichern
		view.getBtIconSave().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doSave();
			}
		});

		// Icon Loeschen
		view.getBtIconDelete().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				doDelete();
			}
		});

		// Author Murillo
		view.getTabbsQuestion().addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				doChangeTabQuestion();
			}
		});

		// Author Murillo
		view.getTabbsAdministration().addChangeListener(new ChangeListener() {
			public void stateChanged(ChangeEvent e) {
				doChangeTabAdmin();
			}
		});
	}

	// Author Dilji
	// ********************************************************************************
	// Methoden
	// ********************************************************************************

	/**
	 * Methode ruft das kleine Hilfe-Fenster auf.
	 */
	private void doViewHelp() {
		String help = "help";
		view.getGuiMini(help);

	}

	/**
	 * Methode ruft das kleine Info-Fenster auf.
	 */
	private void doViewInfo() {
		String info = "info";
		view.getGuiMini(info);
	}

	/**
	 * Methode wechselt in die Home-Ansicht und stellt die richtigen Icons zur
	 * Auswahl.
	 */
	private void doViewHome() {
		view.setLbStatus("Home");
		view.getBtIconHome().setIcon(view.getImgHomeActive());
		view.getBtIconAdministration().setIcon(view.getImgAdministration());

		view.getViewAdministration().setVisible(false);
		view.getViewQuestion().setVisible(true);
		view.getMainCenter().removeAll();
		view.getMainCenter().add(view.getViewQuestion(), BorderLayout.CENTER);
		if (modelV.isActivUserSaved()) {
			if (modelQ.getQuestion() != null)
				modelQ.openQuestion(modelQ.getQuestion().getId());
			modelV.setActivUserSaved(false);
		}
		cOverview.fillData();
		view.getTabbsQuestion().setSelectedIndex(0);
		view.getMainCenter().repaint();
		// Iconleiste
		view.getBtIconSave().setEnabled(false);
		view.getBtIconDelete().setEnabled(true);
		view.getBtIconDelete().setIcon(view.getImgDelete());
		view.getBtIconDelete().setPressedIcon(view.getImgDeleteActive());
		view.getBtIconDelete().setToolTipText("L\u00f6schen");
		view.getBtIconEdit().setVisible(true);
		view.getBtIconEdit().setIcon(view.getImgEdit());
		view.getBtIconEdit().setPressedIcon(view.getImgEditActive());
		view.getBtIconEdit().setToolTipText("Editieren");
	}

	/**
	 * Methode wechselt in die Verwaltung-Ansicht und stellt die richtigen Icons
	 * zur Auswahl.
	 */
	private void doViewAdministration() {
		view.setLbStatus("Verwaltung");
		view.getBtIconAdministration().setIcon(view.getImgAdministrationActive());
		view.getBtIconHome().setIcon(view.getImgHome());

		view.getViewAdministration().setVisible(true);
		view.getViewQuestion().setVisible(false);
		view.getMainCenter().removeAll();
		view.getMainCenter().add(view.getViewAdministration(), BorderLayout.CENTER);
		cAaccount.fillData();
		view.getTabbsAdministration().setSelectedIndex(0);
		if (GlobalRes.getActivUser().isAdmin()) {
			view.getTabbsAdministration().setEnabledAt(1, true);
			cHexAdmin.setOriTextEditable(true);
		} else {
			view.getTabbsAdministration().setEnabledAt(1, false);
			cHexAdmin.setOriTextEditable(false);
		}
		view.getMainCenter().repaint();
		// Iconleiste
		view.getBtIconSave().setEnabled(true);
		view.getBtIconDelete().setEnabled(true);
		view.getBtIconDelete().setIcon(view.getImgReset());
		view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
		view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
	}

	/**
	 * Diese Methode reagiert sobald das Icon 'Neue Frage' geklickt wurde
	 * wechselt zur Sicht Fragestellung.
	 */
	private void doNew() {
		doViewHome();
		cOverview.doNew();
	}

	/**
	 * Diese Methode reagiert sobald das Icon 'Editieren' geklickt wurde und
	 * ruft die entsprechenden Methoden je Ansicht auf.
	 */
	private void doOpen() {
		if ((view.getViewQuestion().isVisible())) {

			switch (view.getTabbsQuestion().getSelectedIndex()) {
			case 0: // Uebersicht
				this.cOverview.doEdit();
				break;
			case 1: // Fragestellung
			case 2: // Kontexthexagramm
			case 3: // Perspektivehexagramm
			case 4: // Komplementaerhexagramm
			case 5: // Wendehexagramm
			case 6: // Nuklear Hexagramm
			case 7: // Fuxihexagramm
			case 8: // Linienhexagramm
				break; // Open-Icon disabled
			}

		} else if ((view.getViewAdministration().isVisible())) {
			switch (view.getTabbsAdministration().getSelectedIndex()) {
			case 0: // Accountdaten
			case 1: // Benutzerverwaltung
				break; // Open-Icon disabled
			case 2: // Kategorieverwaltung
				this.cCatAdmin.doEdit();
				break;
			case 3: // Hexagrammverwaltung
			case 4: // Export
				break; // Open-Icon disabled
			case 5: // Import
				this.cImport.doBrowse();
				break;
			}
		}
	}

	/**
	 * Diese Methode reagiert sobald das Icon 'Speichern' geklickt wurde und
	 * ruft die entsprechenden Methoden je Ansicht auf.
	 */
	private void doSave() {
		if ((view.getViewQuestion().isVisible())) {
			// Home-Ansicht
			switch (view.getTabbsQuestion().getSelectedIndex()) {
			case 0: // Uebersicht
				break; // Save-Icon disabled
			case 1: // Fragestellung
				this.cQuestion.doSave();
				break;
			case 2: // Kontexthexagramm
				this.cKonhex.doSave();
				break;
			case 3: // Perspektivehexagramm
				this.cPerhex.doSave();
				break;
			case 4: // Komplementaerhexagramm
				this.cKomhex.doSave();
				break;
			case 5: // Wendehexagramm
				this.cWenhex.doSave();
				break;
			case 6: // Nuklear Hexagramm
				this.cNukhex.doSave();
				break;
			case 7: // Fuxihexagramm
				this.cFuxhex.doSave();
				break;
			case 8: // Linienhexagramm
				this.cLinhex.doSave();
				break;
			}
			// Verwaltung-Ansicht
		} else if ((view.getViewAdministration().isVisible())) {
			switch (view.getTabbsAdministration().getSelectedIndex()) {
			case 0: // Accountdaten
				this.cAaccount.doSave();
				break;
			case 1: // Benutzerverwaltung
				this.cUserAdmin.doSave();
				break;
			case 2: // Kategorieverwaltung
				break; // Save-Icon disabled
			case 3: // Hexagrammverwaltung
				this.cHexAdmin.getcHex().doSave();
				break;
			case 4: // Export
			case 5: // Import
				break; // Save-Icon disabled

			}
		}
	}

	/**
	 * Diese Methode reagiert sobald das Icon 'Loeschen' oder 'Zuruecksetzten'
	 * geklickt wurde und ruft die entsprechenden Methoden auf.
	 */
	private void doDelete() {
		if ((view.getViewQuestion().isVisible())) {
			// Home-Ansicht
			switch (view.getTabbsQuestion().getSelectedIndex()) {
			case 0: // Uebersicht
				this.cOverview.doDelete();
				break;
			case 1: // Fragestellung
				this.cQuestion.doCancel();
				break;
			case 2: // Kontexthexagramm
				this.cKonhex.doCancel();
				break;
			case 3: // Perspektivehexagramm
				this.cPerhex.doCancel();
				break;
			case 4: // Komplementaerhexagramm
				this.cKomhex.doCancel();
				break;
			case 5: // Wendehexagramm
				this.cWenhex.doCancel();
				break;
			case 6: // Nuklear Hexagramm
				this.cNukhex.doCancel();
				break;
			case 7: // Fuxihexagramm
				this.cFuxhex.doCancel();
				break;
			case 8: // Linienhexagramm
				this.cLinhex.doCancel();
				break;
			}

		} else if ((view.getViewAdministration().isVisible())) {
			// Verwaltung-Ansicht
			switch (view.getTabbsAdministration().getSelectedIndex()) {
			case 0: // Accountdaten
				this.cAaccount.fillData();
				break;
			case 1: // Benutzerverwaltung
				this.cUserAdmin.doDel();
				break;
			case 2: // Kategorieverwaltung
				this.cCatAdmin.doDel();
				break;
			case 3: // Hexagrammverwaltung
				this.cHexAdmin.getcHex().doCancel();
				break;
			case 4: // Export
				this.cExport.doCancel();
				break;
			case 5: // Import
				this.cImport.doCancel();
				break;
			}
		}
	}

	/**
	 * Diese Methode stellt die Tabs der Hexagramme auf aktiviert oder deaktiviert.
	 * @param b gibt an, ob Tabs aktivieren oder deaktivieren
	 */
	private void setHomeHexTabsEnable(boolean b) {
		for (int i = 1; i < view.getTabbsQuestion().getTabCount(); i++) {
			view.getTabbsQuestion().setEnabledAt(i, b);
			view.getTabbsQuestion().setBackgroundAt(i, Color.LIGHT_GRAY);
		}
	}

	/**
	 * Diese Methode reageiert bei einem Wechsel der Tabs der Fragestellung und
	 * fuehrt dazu notwendige Aktionen durch.
	 */
	// Author Murillo/Dilji
	private void doChangeTabQuestion() {
		// Fragen-Ansicht
		switch (view.getTabbsQuestion().getSelectedIndex()) {
		case 0: // Overview
			cOverview.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(false);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgDelete());
			view.getBtIconDelete().setPressedIcon(view.getImgDeleteActive());
			view.getBtIconDelete().setToolTipText("L\u00f6schen");
			view.getBtIconEdit().setVisible(true);
			view.getBtIconEdit().setIcon(view.getImgEdit());
			view.getBtIconEdit().setPressedIcon(view.getImgEditActive());
			view.getBtIconEdit().setToolTipText("Editieren");
		case 1: // Fragestellung
			cQuestion.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 2:// Kontexthexagram
			if (modelQ.getQuestion() != null)
				modelQ.setHexagram(modelQ.getQuestion().getHex()[0]);
			cKonhex.setHexLines();
			if (view.getTabKonhex().getLiKlist().getSelectedIndex() == -1)
				view.getTabKonhex().getLiKlist().setSelectedIndex(0);
			else
				cKonhex.doTextChange(view.getTabKonhex().getLiKlist().getSelectedIndex(), -1);
			cKonhex.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 3:// Perpesktivhexagram
			if (modelQ.getQuestion() != null)
				modelQ.setHexagram(modelQ.getQuestion().getHex()[1]);
			cPerhex.setHexLines();
			if (view.getTabPerhex().getLiKlist().getSelectedIndex() == -1)
				view.getTabPerhex().getLiKlist().setSelectedIndex(0);
			else
				cPerhex.doTextChange(view.getTabPerhex().getLiKlist().getSelectedIndex(), -1);
			cPerhex.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 4:// Komplementaerhexagramm
			if (modelQ.getQuestion() != null)
				modelQ.setHexagram(modelQ.getQuestion().getHex()[2]);
			cKomhex.setHexLines();
			if (view.getTabKomhex().getLiKlist().getSelectedIndex() == -1)
				view.getTabKomhex().getLiKlist().setSelectedIndex(0);
			else
				cKomhex.doTextChange(view.getTabKomhex().getLiKlist().getSelectedIndex(), -1);
			cKomhex.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 5:// Wendehexagramm
			if (modelQ.getQuestion() != null)
				modelQ.setHexagram(modelQ.getQuestion().getHex()[3]);
			cWenhex.setHexLines();
			if (view.getTabWenhex().getLiKlist().getSelectedIndex() == -1)
				view.getTabWenhex().getLiKlist().setSelectedIndex(0);
			else
				cWenhex.doTextChange(view.getTabWenhex().getLiKlist().getSelectedIndex(), -1);
			cWenhex.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 6:// Nuklearhexagramm
			if (modelQ.getQuestion() != null)
				modelQ.setHexagram(modelQ.getQuestion().getHex()[4]);
			cNukhex.setHexLines();
			if (view.getTabNukhex().getLiKlist().getSelectedIndex() == -1)
				view.getTabNukhex().getLiKlist().setSelectedIndex(0);
			else
				cNukhex.doTextChange(view.getTabNukhex().getLiKlist().getSelectedIndex(), -1);
			cNukhex.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 7:// Fuxihexagramm
			if (modelQ.getQuestion() != null)
				modelQ.setHexagram(modelQ.getQuestion().getHex()[5]);
			cFuxhex.setHexLines();
			if (view.getTabFuxhex().getLiKlist().getSelectedIndex() == -1)
				view.getTabFuxhex().getLiKlist().setSelectedIndex(0);
			else
				cFuxhex.doTextChange(view.getTabFuxhex().getLiKlist().getSelectedIndex(), -1);
			cFuxhex.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 8:// Linienhexagramme
			if (modelQ.getQuestion() != null)
				modelQ.setHexagram(modelQ.getQuestion().getHex()[0]);
			cLinhex.setHexLines();
			if (view.getTabLinhex().getLiKlist().getSelectedIndex() == -1)
				view.getTabLinhex().getLiKlist().setSelectedIndex(0);

			cLinhex.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		default:
			break;
		}
	}

	/**
	 * Diese Methode reageiert bei einem Wechsel der Tabs der Verwaltung und
	 * fuehrt datz notwendige Aktionen durch
	 */
	// Author Murillo/Dilji
	private void doChangeTabAdmin() {
		// Verwaltung-Sicht
		switch (view.getTabbsAdministration().getSelectedIndex()) {
		case 0: // Accaountdaten
			cAaccount.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 1:// Benutzeradministration
			cUserAdmin.fillListData();
			cUserAdmin.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgDelete());
			view.getBtIconDelete().setPressedIcon(view.getImgDeleteActive());
			view.getBtIconDelete().setToolTipText("L\u00f6schen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 2:// Kategorieadministration
			cCatAdmin.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(false);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgDelete());
			view.getBtIconDelete().setPressedIcon(view.getImgDeleteActive());
			view.getBtIconDelete().setToolTipText("L\u00f6schen");
			view.getBtIconEdit().setVisible(true);
			view.getBtIconEdit().setIcon(view.getImgEdit());
			view.getBtIconEdit().setPressedIcon(view.getImgEditActive());
			view.getBtIconEdit().setToolTipText("Editieren");
			break;
		case 3:// Hexagrammadministration
			cHexAdmin.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(true);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 4:// Export
			cExport.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(false);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(false);
			break;
		case 5:// Import
			cImport.fillData();
			// Iconleiste
			view.getBtIconSave().setEnabled(false);
			view.getBtIconDelete().setEnabled(true);
			view.getBtIconDelete().setIcon(view.getImgReset());
			view.getBtIconDelete().setPressedIcon(view.getImgResetActive());
			view.getBtIconDelete().setToolTipText("Zur\u00fccksetzen");
			view.getBtIconEdit().setVisible(true);
			view.getBtIconEdit().setIcon(view.getImgSearch());
			view.getBtIconEdit().setPressedIcon(view.getImgSearchActive());
			view.getBtIconEdit().setToolTipText("Durchsuchen...");
			break;
		default:
			break;
		}
	}
}
